package itens;

import org.anddev.andengine.audio.sound.SoundManager;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.TextureManager;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;

import android.content.Context;
import assets.Som;

public class Vida extends Item {

	public Vida(int x, int y, Context contexto, TextureManager tm, SoundManager sm) {
		this.x = x;
		this.y = y;
		
		mapaDeTexturas = new BitmapTextureAtlas(64, 64, TextureOptions.BILINEAR);
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		textura = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mapaDeTexturas, contexto, "Vida.png", 0, 0);
		tm.loadTexture(mapaDeTexturas);
		
		sprite = new Sprite(x, y, textura);
		
		colisao = new Som("Item adquirido.ogg", contexto, sm);
	}

	@Override
	public boolean colidiuComCaoGuia(AnimatedSprite caoGuia) {
		if(caoGuia.collidesWith(sprite)){
			euExisto = false;
			return true;
		}else{
			return false;
		}
	}
	
	@Override
	public void tocaSom() {
		colisao.som.play();
	}
	
	@Override
	public void posicionaNaCena(int mapx, int mapy) {
		sprite.setPosition((int)x-mapx, (int)y-mapy);
	}

}
